$.ajax({
    type: 'get',
    url: '/posts',
    success: function (response) {
        var html = template('postsTpl', response);
        $('#postsBox').html(html);
        var page = template('pagesTpl', response);
        $('#pagesBox').html(page);
    }
});
// 处理日期时间格式
function formateDate(date) {
    // 将日期时间字符串转换成日期对象
    date = new Date(date);
    return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
};
// 分页
function changePage(page) {
    // 向服务器端发送请求 获取文章列表数据
    $.ajax({
        type: 'get',
        url: '/posts',
        data: {
            page: page
        },
        success: function (response) {
            var html = template('postsTpl', response);
            $('#postsBox').html(html);
            var page = template('pagesTpl', response);
            $('#pagesBox').html(page);
        }
    });
};
$.ajax({
    type: 'get',
    url: '/categories',
    success: function (response) {
        var html = template('categoryTpl', { data: response });
        $('#categoryBox').html(html);
    }
});
$('#filterForm').on('submit', function () {
    var formData = $(this).serialize();
    console.log(formData);

    $.ajax({
        type: 'get',
        url: '/posts',
        data: formData,
        success: function (response) {
            var html = template('postsTpl', response);
            $('#postsBox').html(html);
            var page = template('pagesTpl', response);
            $('#pagesBox').html(page);
        }
    });
    return false
})